package pl.us.ij.plugins.segmentation.forms;

import com.intellij.uiDesigner.core.Spacer;
import com.jgoodies.forms.layout.CellConstraints;
import com.jgoodies.forms.layout.FormLayout;
import pl.us.ij.plugins.segmentation.commands.MatrixHelper;
import pl.us.ij.plugins.segmentation.commands.edges.DetectEdgesCommand;
import pl.us.ij.plugins.segmentation.commands.edges.DetectEdgesCommandParams;
import pl.us.ij.plugins.segmentation.infrastructure.CategoryInfo;
import pl.us.ij.plugins.segmentation.infrastructure.CommandParams;
import pl.us.ij.plugins.segmentation.localization.Localization;

import javax.swing.*;
import javax.swing.border.TitledBorder;
import java.awt.*;
import java.util.ResourceBundle;

/**
 * Created by IntelliJ IDEA.
 * User: Przemek
 * Date: 2010-05-26
 * Time: 00:24:55
 * To change this template use File | Settings | File Templates.
 */
public class EdgesMasksForm extends CategoryInfo {
    private JTabbedPane maskTabbedPane;
    private JPanel robertsPanel;
    private JPanel matrix3x3Panel;
    private JRadioButton robertsRadioButton1;
    private JRadioButton robertsRadioButton2;
    private JRadioButton robertsRadioButton3;
    private JRadioButton robertsRadioButton4;
    private JPanel prewittPanel;
    private JRadioButton prewittRadioButton1;
    private JRadioButton prewittRadioButton2;
    private JPanel sobelPanel;
    private JRadioButton sobelRadioButton1;
    private JRadioButton sobelRadioButton2;
    private JPanel laplasPanel;
    private JRadioButton laplasRadioButton1;
    private JRadioButton laplasRadioButton2;
    private JButton detectEdgesButton;
    private JPanel masksPanel;
    private JRadioButton replaceImageRadioButton;

    public EdgesMasksForm(IActionHandler actionHandler) {
        actionHandler.setAction(detectEdgesButton, DetectEdgesCommand.class, getDetectEdgesParams());
    }

    @Override
    public String getTitle() {
        return Localization.getString("edgesMasksForm.title");
    }

    @Override
    public JPanel getPanel() {
        return masksPanel;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public String getDescription() {
        return null;  //To change body of implemented methods use File | Settings | File Templates.
    }

    private ICommandParamGather getDetectEdgesParams() {
        return new ICommandParamGather() {
            public CommandParams getCommandParams() {
                DetectEdgesCommandParams params = new DetectEdgesCommandParams();
                params.setReplacePixels(replaceImageRadioButton.isSelected());
                params.setMask(getMask());
                params.setLaplace(maskTabbedPane.getSelectedComponent() == laplasPanel);
                return params;
            }
        };
    }

    private float[][] getMask() {
        if (maskTabbedPane.getSelectedComponent() == robertsPanel) {
            if (robertsRadioButton1.isSelected()) {
                return MatrixHelper.floatMatrix(3,
                        0, 0, 0,
                        0, -1, 1,
                        0, 0, 0);
            } else if (robertsRadioButton2.isSelected()) {
                return MatrixHelper.floatMatrix(3,
                        0, 0, 0,
                        0, -1, 0,
                        0, 0, 1);
            } else if (robertsRadioButton3.isSelected()) {
                return MatrixHelper.floatMatrix(3,
                        0, 0, 0,
                        0, -1, 0,
                        0, 1, 0);
            } else if (robertsRadioButton4.isSelected()) {
                return MatrixHelper.floatMatrix(3,
                        0, 0, 0,
                        0, -1, 0,
                        1, 0, 0);
            }
        } else if (maskTabbedPane.getSelectedComponent() == prewittPanel) {
            if (prewittRadioButton1.isSelected()) {
                return MatrixHelper.floatMatrix(3,
                        1, 1, 1,
                        0, 0, 0,
                        -1, -1, -1);
            } else if (prewittRadioButton2.isSelected()) {
                return MatrixHelper.floatMatrix(3,
                        -1, 0, 1,
                        -1, 0, 1,
                        -1, 0, 1);
            }
        } else if (maskTabbedPane.getSelectedComponent() == sobelPanel) {
            if (sobelRadioButton1.isSelected()) {
                return MatrixHelper.floatMatrix(3,
                        1, 2, 1,
                        0, 0, 0,
                        -1, -2, -1);
            } else if (sobelRadioButton2.isSelected()) {
                return MatrixHelper.floatMatrix(3,
                        -1, 0, 1,
                        -2, 0, 2,
                        -1, 0, 1);
            }
        } else if (maskTabbedPane.getSelectedComponent() == laplasPanel) {
            if (laplasRadioButton1.isSelected()) {
                return MatrixHelper.floatMatrix(3,
                        0, 1, 0,
                        1, -4, 1,
                        0, 1, 0);
            } else if (laplasRadioButton2.isSelected()) {
                return MatrixHelper.floatMatrix(3,
                        1, 1, 1,
                        1, -8, 1,
                        1, 1, 1);
            }
        }

        return MatrixHelper.floatZeros(3);
    }

    {
// GUI initializer generated by IntelliJ IDEA GUI Designer
// >>> IMPORTANT!! <<<
// DO NOT EDIT OR ADD ANY CODE HERE!
        $$$setupUI$$$();
    }

    /**
     * Method generated by IntelliJ IDEA GUI Designer
     * >>> IMPORTANT!! <<<
     * DO NOT edit this method OR call it in your code!
     *
     * @noinspection ALL
     */
    private void $$$setupUI$$$() {
        final JPanel panel1 = new JPanel();
        panel1.setLayout(new FormLayout("fill:d:noGrow", "center:d:noGrow"));
        masksPanel = new JPanel();
        masksPanel.setLayout(new FormLayout("fill:214px:noGrow,left:4dlu:noGrow,fill:219px:noGrow", "center:max(d;4px):noGrow,top:4dlu:noGrow,center:max(d;4px):noGrow"));
        CellConstraints cc = new CellConstraints();
        panel1.add(masksPanel, cc.xy(1, 1));
        maskTabbedPane = new JTabbedPane();
        maskTabbedPane.setTabPlacement(2);
        masksPanel.add(maskTabbedPane, cc.xyw(1, 1, 3, CellConstraints.DEFAULT, CellConstraints.FILL));
        robertsPanel = new JPanel();
        robertsPanel.setLayout(new FormLayout("fill:d:noGrow,left:4dlu:noGrow,fill:max(d;4px):noGrow,left:4dlu:noGrow,fill:max(d;4px):noGrow,left:4dlu:noGrow,fill:max(d;4px):noGrow", "center:d:noGrow,top:4dlu:noGrow,center:d:grow,top:4dlu:noGrow,center:max(d;4px):noGrow"));
        maskTabbedPane.addTab(ResourceBundle.getBundle("pl/us/ij/plugins/segmentation/localization/Localization").getString("edgesMasksForm.robertsTabLabel"), robertsPanel);
        matrix3x3Panel = new JPanel();
        matrix3x3Panel.setLayout(new FormLayout("fill:d:noGrow,left:4dlu:noGrow,fill:max(d;4px):noGrow,left:4dlu:noGrow,fill:max(d;4px):noGrow", "center:d:noGrow,top:4dlu:noGrow,center:max(d;4px):noGrow,top:4dlu:noGrow,center:max(d;4px):noGrow"));
        matrix3x3Panel.setBackground(new Color(-1));
        robertsPanel.add(matrix3x3Panel, cc.xy(1, 1));
        matrix3x3Panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.black), null, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, new Color(-16777216)));
        final JLabel label1 = new JLabel();
        label1.setBackground(new Color(-1));
        label1.setHorizontalAlignment(0);
        label1.setHorizontalTextPosition(0);
        label1.setText("  0  ");
        matrix3x3Panel.add(label1, cc.xy(1, 1));
        final JLabel label2 = new JLabel();
        label2.setText("  0  ");
        matrix3x3Panel.add(label2, cc.xy(1, 3));
        final JLabel label3 = new JLabel();
        label3.setText("  0  ");
        matrix3x3Panel.add(label3, cc.xy(1, 5));
        final JLabel label4 = new JLabel();
        label4.setText("  0  ");
        matrix3x3Panel.add(label4, cc.xy(3, 1));
        final JLabel label5 = new JLabel();
        label5.setText(" -1");
        matrix3x3Panel.add(label5, cc.xy(3, 3));
        final JLabel label6 = new JLabel();
        label6.setText("  0  ");
        matrix3x3Panel.add(label6, cc.xy(3, 5));
        final JLabel label7 = new JLabel();
        label7.setText("  0  ");
        matrix3x3Panel.add(label7, cc.xy(5, 1));
        final JLabel label8 = new JLabel();
        label8.setText("  1");
        matrix3x3Panel.add(label8, cc.xy(5, 3));
        final JLabel label9 = new JLabel();
        label9.setText("  0  ");
        matrix3x3Panel.add(label9, cc.xy(5, 5));
        final JPanel panel2 = new JPanel();
        panel2.setLayout(new FormLayout("fill:d:noGrow,left:4dlu:noGrow,fill:max(d;4px):noGrow,left:4dlu:noGrow,fill:max(d;4px):noGrow", "center:d:noGrow,top:4dlu:noGrow,center:max(d;4px):noGrow,top:4dlu:noGrow,center:max(d;4px):noGrow"));
        panel2.setBackground(new Color(-1));
        robertsPanel.add(panel2, cc.xy(3, 1));
        panel2.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.black), null, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, new Color(-16777216)));
        final JLabel label10 = new JLabel();
        label10.setBackground(new Color(-1));
        label10.setHorizontalAlignment(0);
        label10.setHorizontalTextPosition(0);
        label10.setText("  0  ");
        panel2.add(label10, cc.xy(1, 1));
        final JLabel label11 = new JLabel();
        label11.setText("  0  ");
        panel2.add(label11, cc.xy(1, 3));
        final JLabel label12 = new JLabel();
        label12.setText("  0  ");
        panel2.add(label12, cc.xy(1, 5));
        final JLabel label13 = new JLabel();
        label13.setText("  0  ");
        panel2.add(label13, cc.xy(3, 1));
        final JLabel label14 = new JLabel();
        label14.setText(" -1");
        panel2.add(label14, cc.xy(3, 3));
        final JLabel label15 = new JLabel();
        label15.setText("  0  ");
        panel2.add(label15, cc.xy(3, 5));
        final JLabel label16 = new JLabel();
        label16.setText("  0  ");
        panel2.add(label16, cc.xy(5, 1));
        final JLabel label17 = new JLabel();
        label17.setText("  0  ");
        panel2.add(label17, cc.xy(5, 3));
        final JLabel label18 = new JLabel();
        label18.setText("  1  ");
        panel2.add(label18, cc.xy(5, 5));
        final JPanel panel3 = new JPanel();
        panel3.setLayout(new FormLayout("fill:d:noGrow,left:4dlu:noGrow,fill:max(d;4px):noGrow,left:4dlu:noGrow,fill:max(d;4px):noGrow", "center:d:noGrow,top:4dlu:noGrow,center:max(d;4px):noGrow,top:4dlu:noGrow,center:max(d;4px):noGrow"));
        panel3.setBackground(new Color(-1));
        robertsPanel.add(panel3, cc.xy(5, 1));
        panel3.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.black), null, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, new Color(-16777216)));
        final JLabel label19 = new JLabel();
        label19.setBackground(new Color(-1));
        label19.setHorizontalAlignment(0);
        label19.setHorizontalTextPosition(0);
        label19.setText("  0  ");
        panel3.add(label19, cc.xy(1, 1));
        final JLabel label20 = new JLabel();
        label20.setText("  0  ");
        panel3.add(label20, cc.xy(1, 3));
        final JLabel label21 = new JLabel();
        label21.setText("  0  ");
        panel3.add(label21, cc.xy(1, 5));
        final JLabel label22 = new JLabel();
        label22.setText("  0  ");
        panel3.add(label22, cc.xy(3, 1));
        final JLabel label23 = new JLabel();
        label23.setText(" -1  ");
        panel3.add(label23, cc.xy(3, 3));
        final JLabel label24 = new JLabel();
        label24.setText("  1");
        panel3.add(label24, cc.xy(3, 5));
        final JLabel label25 = new JLabel();
        label25.setText("  0  ");
        panel3.add(label25, cc.xy(5, 1));
        final JLabel label26 = new JLabel();
        label26.setText("  0  ");
        panel3.add(label26, cc.xy(5, 3));
        final JLabel label27 = new JLabel();
        label27.setText("  0  ");
        panel3.add(label27, cc.xy(5, 5));
        final JPanel panel4 = new JPanel();
        panel4.setLayout(new FormLayout("fill:d:noGrow,left:4dlu:noGrow,fill:max(d;4px):noGrow,left:4dlu:noGrow,fill:max(d;4px):noGrow", "center:d:noGrow,top:4dlu:noGrow,center:max(d;4px):noGrow,top:4dlu:noGrow,center:max(d;4px):noGrow"));
        panel4.setBackground(new Color(-1));
        robertsPanel.add(panel4, cc.xy(7, 1));
        panel4.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.black), null, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, new Color(-16777216)));
        final JLabel label28 = new JLabel();
        label28.setBackground(new Color(-1));
        label28.setHorizontalAlignment(0);
        label28.setHorizontalTextPosition(0);
        label28.setText("  0  ");
        panel4.add(label28, cc.xy(1, 1));
        final JLabel label29 = new JLabel();
        label29.setText("  0  ");
        panel4.add(label29, cc.xy(1, 3));
        final JLabel label30 = new JLabel();
        label30.setText("  1  ");
        panel4.add(label30, cc.xy(1, 5));
        final JLabel label31 = new JLabel();
        label31.setText("  0  ");
        panel4.add(label31, cc.xy(3, 1));
        final JLabel label32 = new JLabel();
        label32.setText(" -1  ");
        panel4.add(label32, cc.xy(3, 3));
        final JLabel label33 = new JLabel();
        label33.setText("  0  ");
        panel4.add(label33, cc.xy(3, 5));
        final JLabel label34 = new JLabel();
        label34.setText("  0  ");
        panel4.add(label34, cc.xy(5, 1));
        final JLabel label35 = new JLabel();
        label35.setText("  0  ");
        panel4.add(label35, cc.xy(5, 3));
        final JLabel label36 = new JLabel();
        label36.setText("  0  ");
        panel4.add(label36, cc.xy(5, 5));
        robertsRadioButton1 = new JRadioButton();
        robertsRadioButton1.setSelected(true);
        robertsRadioButton1.setText("");
        robertsPanel.add(robertsRadioButton1, cc.xy(1, 5, CellConstraints.CENTER, CellConstraints.DEFAULT));
        robertsRadioButton2 = new JRadioButton();
        robertsRadioButton2.setText("");
        robertsPanel.add(robertsRadioButton2, cc.xy(3, 5, CellConstraints.CENTER, CellConstraints.DEFAULT));
        robertsRadioButton3 = new JRadioButton();
        robertsRadioButton3.setText("");
        robertsPanel.add(robertsRadioButton3, cc.xy(5, 5, CellConstraints.CENTER, CellConstraints.DEFAULT));
        robertsRadioButton4 = new JRadioButton();
        robertsRadioButton4.setText("");
        robertsPanel.add(robertsRadioButton4, cc.xy(7, 5, CellConstraints.CENTER, CellConstraints.DEFAULT));
        final com.intellij.uiDesigner.core.Spacer spacer1 = new com.intellij.uiDesigner.core.Spacer();
        robertsPanel.add(spacer1, cc.xy(1, 3, CellConstraints.DEFAULT, CellConstraints.FILL));
        final com.intellij.uiDesigner.core.Spacer spacer2 = new com.intellij.uiDesigner.core.Spacer();
        robertsPanel.add(spacer2, cc.xy(3, 3, CellConstraints.DEFAULT, CellConstraints.FILL));
        final com.intellij.uiDesigner.core.Spacer spacer3 = new com.intellij.uiDesigner.core.Spacer();
        robertsPanel.add(spacer3, cc.xy(5, 3, CellConstraints.DEFAULT, CellConstraints.FILL));
        final com.intellij.uiDesigner.core.Spacer spacer4 = new com.intellij.uiDesigner.core.Spacer();
        robertsPanel.add(spacer4, cc.xy(7, 3, CellConstraints.DEFAULT, CellConstraints.FILL));
        prewittPanel = new JPanel();
        prewittPanel.setLayout(new FormLayout("fill:d:noGrow,left:4dlu:noGrow,fill:max(d;4px):noGrow", "center:d:noGrow,top:4dlu:noGrow,center:max(d;4px):noGrow,top:4dlu:noGrow,center:max(d;4px):noGrow"));
        maskTabbedPane.addTab(ResourceBundle.getBundle("pl/us/ij/plugins/segmentation/localization/Localization").getString("edgesMasksForm.prewittTabLabel"), prewittPanel);
        final JPanel panel5 = new JPanel();
        panel5.setLayout(new FormLayout("fill:d:noGrow,left:4dlu:noGrow,fill:max(d;4px):noGrow,left:4dlu:noGrow,fill:max(d;4px):noGrow", "center:d:noGrow,top:4dlu:noGrow,center:max(d;4px):noGrow,top:4dlu:noGrow,center:max(d;4px):noGrow"));
        panel5.setBackground(new Color(-1));
        prewittPanel.add(panel5, cc.xy(1, 1));
        panel5.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.black), null, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, new Color(-16777216)));
        final JLabel label37 = new JLabel();
        label37.setBackground(new Color(-1));
        label37.setHorizontalAlignment(0);
        label37.setHorizontalTextPosition(0);
        label37.setText("  1  ");
        panel5.add(label37, cc.xy(1, 1));
        final JLabel label38 = new JLabel();
        label38.setText("  0  ");
        panel5.add(label38, cc.xy(1, 3));
        final JLabel label39 = new JLabel();
        label39.setText(" -1  ");
        panel5.add(label39, cc.xy(1, 5));
        final JLabel label40 = new JLabel();
        label40.setText("  1  ");
        panel5.add(label40, cc.xy(3, 1));
        final JLabel label41 = new JLabel();
        label41.setText("  0  ");
        panel5.add(label41, cc.xy(3, 3));
        final JLabel label42 = new JLabel();
        label42.setText(" -1  ");
        panel5.add(label42, cc.xy(3, 5));
        final JLabel label43 = new JLabel();
        label43.setText("  1  ");
        panel5.add(label43, cc.xy(5, 1));
        final JLabel label44 = new JLabel();
        label44.setText("  0  ");
        panel5.add(label44, cc.xy(5, 3));
        final JLabel label45 = new JLabel();
        label45.setText(" -1  ");
        panel5.add(label45, cc.xy(5, 5));
        final JPanel panel6 = new JPanel();
        panel6.setLayout(new FormLayout("fill:d:noGrow,left:4dlu:noGrow,fill:max(d;4px):noGrow,left:4dlu:noGrow,fill:max(d;4px):noGrow", "center:d:noGrow,top:4dlu:noGrow,center:max(d;4px):noGrow,top:4dlu:noGrow,center:max(d;4px):noGrow"));
        panel6.setBackground(new Color(-1));
        prewittPanel.add(panel6, cc.xy(3, 1));
        panel6.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.black), null, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, new Color(-16777216)));
        final JLabel label46 = new JLabel();
        label46.setBackground(new Color(-1));
        label46.setHorizontalAlignment(0);
        label46.setHorizontalTextPosition(0);
        label46.setText(" -1  ");
        panel6.add(label46, cc.xy(1, 1));
        final JLabel label47 = new JLabel();
        label47.setText(" -1  ");
        panel6.add(label47, cc.xy(1, 3));
        final JLabel label48 = new JLabel();
        label48.setText(" -1  ");
        panel6.add(label48, cc.xy(1, 5));
        final JLabel label49 = new JLabel();
        label49.setText("  0  ");
        panel6.add(label49, cc.xy(3, 1));
        final JLabel label50 = new JLabel();
        label50.setText("  0  ");
        panel6.add(label50, cc.xy(3, 3));
        final JLabel label51 = new JLabel();
        label51.setText("  0  ");
        panel6.add(label51, cc.xy(3, 5));
        final JLabel label52 = new JLabel();
        label52.setText("  1  ");
        panel6.add(label52, cc.xy(5, 1));
        final JLabel label53 = new JLabel();
        label53.setText("  1  ");
        panel6.add(label53, cc.xy(5, 3));
        final JLabel label54 = new JLabel();
        label54.setText("  1  ");
        panel6.add(label54, cc.xy(5, 5));
        prewittRadioButton2 = new JRadioButton();
        prewittRadioButton2.setText("");
        prewittPanel.add(prewittRadioButton2, cc.xy(3, 5, CellConstraints.CENTER, CellConstraints.DEFAULT));
        final com.intellij.uiDesigner.core.Spacer spacer5 = new com.intellij.uiDesigner.core.Spacer();
        prewittPanel.add(spacer5, cc.xy(1, 3, CellConstraints.DEFAULT, CellConstraints.FILL));
        final com.intellij.uiDesigner.core.Spacer spacer6 = new com.intellij.uiDesigner.core.Spacer();
        prewittPanel.add(spacer6, cc.xy(3, 3, CellConstraints.DEFAULT, CellConstraints.FILL));
        prewittRadioButton1 = new JRadioButton();
        prewittRadioButton1.setSelected(true);
        prewittRadioButton1.setText("");
        prewittPanel.add(prewittRadioButton1, cc.xy(1, 5, CellConstraints.CENTER, CellConstraints.DEFAULT));
        sobelPanel = new JPanel();
        sobelPanel.setLayout(new FormLayout("fill:d:noGrow,left:4dlu:noGrow,fill:max(d;4px):noGrow", "center:d:noGrow,top:4dlu:noGrow,center:max(d;4px):noGrow,top:4dlu:noGrow,center:max(d;4px):noGrow"));
        maskTabbedPane.addTab(ResourceBundle.getBundle("pl/us/ij/plugins/segmentation/localization/Localization").getString("edgesMasksForm.sobelTabLabel"), sobelPanel);
        final JPanel panel7 = new JPanel();
        panel7.setLayout(new FormLayout("fill:d:noGrow,left:4dlu:noGrow,fill:max(d;4px):noGrow,left:4dlu:noGrow,fill:max(d;4px):noGrow", "center:d:noGrow,top:4dlu:noGrow,center:max(d;4px):noGrow,top:4dlu:noGrow,center:max(d;4px):noGrow"));
        panel7.setBackground(new Color(-1));
        sobelPanel.add(panel7, cc.xy(1, 1));
        panel7.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.black), null, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, new Color(-16777216)));
        final JLabel label55 = new JLabel();
        label55.setBackground(new Color(-1));
        label55.setHorizontalAlignment(0);
        label55.setHorizontalTextPosition(0);
        label55.setText("  1  ");
        panel7.add(label55, cc.xy(1, 1));
        final JLabel label56 = new JLabel();
        label56.setText("  0  ");
        panel7.add(label56, cc.xy(1, 3));
        final JLabel label57 = new JLabel();
        label57.setText(" -1  ");
        panel7.add(label57, cc.xy(1, 5));
        final JLabel label58 = new JLabel();
        label58.setText("  2  ");
        panel7.add(label58, cc.xy(3, 1));
        final JLabel label59 = new JLabel();
        label59.setText("  0  ");
        panel7.add(label59, cc.xy(3, 3));
        final JLabel label60 = new JLabel();
        label60.setText(" -2  ");
        panel7.add(label60, cc.xy(3, 5));
        final JLabel label61 = new JLabel();
        label61.setText("  1  ");
        panel7.add(label61, cc.xy(5, 1));
        final JLabel label62 = new JLabel();
        label62.setText("  0  ");
        panel7.add(label62, cc.xy(5, 3));
        final JLabel label63 = new JLabel();
        label63.setText(" -1  ");
        panel7.add(label63, cc.xy(5, 5));
        final JPanel panel8 = new JPanel();
        panel8.setLayout(new FormLayout("fill:d:noGrow,left:4dlu:noGrow,fill:max(d;4px):noGrow,left:4dlu:noGrow,fill:max(d;4px):noGrow", "center:d:noGrow,top:4dlu:noGrow,center:max(d;4px):noGrow,top:4dlu:noGrow,center:max(d;4px):noGrow"));
        panel8.setBackground(new Color(-1));
        sobelPanel.add(panel8, cc.xy(3, 1));
        panel8.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.black), null, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, new Color(-16777216)));
        final JLabel label64 = new JLabel();
        label64.setBackground(new Color(-1));
        label64.setHorizontalAlignment(0);
        label64.setHorizontalTextPosition(0);
        label64.setText(" -1  ");
        panel8.add(label64, cc.xy(1, 1));
        final JLabel label65 = new JLabel();
        label65.setText(" -2  ");
        panel8.add(label65, cc.xy(1, 3));
        final JLabel label66 = new JLabel();
        label66.setText(" -1  ");
        panel8.add(label66, cc.xy(1, 5));
        final JLabel label67 = new JLabel();
        label67.setText("  0  ");
        panel8.add(label67, cc.xy(3, 1));
        final JLabel label68 = new JLabel();
        label68.setText("  0  ");
        panel8.add(label68, cc.xy(3, 3));
        final JLabel label69 = new JLabel();
        label69.setText("  0  ");
        panel8.add(label69, cc.xy(3, 5));
        final JLabel label70 = new JLabel();
        label70.setText("  1  ");
        panel8.add(label70, cc.xy(5, 1));
        final JLabel label71 = new JLabel();
        label71.setText("  2  ");
        panel8.add(label71, cc.xy(5, 3));
        final JLabel label72 = new JLabel();
        label72.setText("  1  ");
        panel8.add(label72, cc.xy(5, 5));
        sobelRadioButton1 = new JRadioButton();
        sobelRadioButton1.setSelected(true);
        sobelRadioButton1.setText("");
        sobelPanel.add(sobelRadioButton1, cc.xy(1, 5, CellConstraints.CENTER, CellConstraints.DEFAULT));
        sobelRadioButton2 = new JRadioButton();
        sobelRadioButton2.setText("");
        sobelPanel.add(sobelRadioButton2, cc.xy(3, 5, CellConstraints.CENTER, CellConstraints.DEFAULT));
        final com.intellij.uiDesigner.core.Spacer spacer7 = new com.intellij.uiDesigner.core.Spacer();
        sobelPanel.add(spacer7, cc.xy(1, 3, CellConstraints.DEFAULT, CellConstraints.FILL));
        final com.intellij.uiDesigner.core.Spacer spacer8 = new com.intellij.uiDesigner.core.Spacer();
        sobelPanel.add(spacer8, cc.xy(3, 3, CellConstraints.DEFAULT, CellConstraints.FILL));
        laplasPanel = new JPanel();
        laplasPanel.setLayout(new FormLayout("fill:d:noGrow,left:4dlu:noGrow,fill:max(d;4px):noGrow", "center:d:noGrow,top:4dlu:noGrow,center:max(d;4px):noGrow,top:4dlu:noGrow,center:max(d;4px):noGrow"));
        maskTabbedPane.addTab(ResourceBundle.getBundle("pl/us/ij/plugins/segmentation/localization/Localization").getString("edgesMasksForm.laplaceTabLabel"), laplasPanel);
        final JPanel panel9 = new JPanel();
        panel9.setLayout(new FormLayout("fill:d:noGrow,left:4dlu:noGrow,fill:max(d;4px):noGrow,left:4dlu:noGrow,fill:max(d;4px):noGrow", "center:d:noGrow,top:4dlu:noGrow,center:max(d;4px):noGrow,top:4dlu:noGrow,center:max(d;4px):noGrow"));
        panel9.setBackground(new Color(-1));
        laplasPanel.add(panel9, cc.xy(1, 1));
        panel9.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.black), null, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, new Color(-16777216)));
        final JLabel label73 = new JLabel();
        label73.setBackground(new Color(-1));
        label73.setHorizontalAlignment(0);
        label73.setHorizontalTextPosition(0);
        label73.setText("  0  ");
        panel9.add(label73, cc.xy(1, 1));
        final JLabel label74 = new JLabel();
        label74.setText("  1  ");
        panel9.add(label74, cc.xy(1, 3));
        final JLabel label75 = new JLabel();
        label75.setText("  0  ");
        panel9.add(label75, cc.xy(1, 5));
        final JLabel label76 = new JLabel();
        label76.setText("  1  ");
        panel9.add(label76, cc.xy(3, 1));
        final JLabel label77 = new JLabel();
        label77.setText(" -4  ");
        panel9.add(label77, cc.xy(3, 3));
        final JLabel label78 = new JLabel();
        label78.setText("  1  ");
        panel9.add(label78, cc.xy(3, 5));
        final JLabel label79 = new JLabel();
        label79.setText("  0  ");
        panel9.add(label79, cc.xy(5, 1));
        final JLabel label80 = new JLabel();
        label80.setText("  1  ");
        panel9.add(label80, cc.xy(5, 3));
        final JLabel label81 = new JLabel();
        label81.setText("  0  ");
        panel9.add(label81, cc.xy(5, 5));
        final JPanel panel10 = new JPanel();
        panel10.setLayout(new FormLayout("fill:d:noGrow,left:4dlu:noGrow,fill:max(d;4px):noGrow,left:4dlu:noGrow,fill:max(d;4px):noGrow", "center:d:noGrow,top:4dlu:noGrow,center:max(d;4px):noGrow,top:4dlu:noGrow,center:max(d;4px):noGrow"));
        panel10.setBackground(new Color(-1));
        laplasPanel.add(panel10, cc.xy(3, 1));
        panel10.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.black), null, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, new Color(-16777216)));
        final JLabel label82 = new JLabel();
        label82.setBackground(new Color(-1));
        label82.setHorizontalAlignment(0);
        label82.setHorizontalTextPosition(0);
        label82.setText("  1  ");
        panel10.add(label82, cc.xy(1, 1));
        final JLabel label83 = new JLabel();
        label83.setText("  1  ");
        panel10.add(label83, cc.xy(1, 3));
        final JLabel label84 = new JLabel();
        label84.setText("  1  ");
        panel10.add(label84, cc.xy(1, 5));
        final JLabel label85 = new JLabel();
        label85.setText("  1  ");
        panel10.add(label85, cc.xy(3, 1));
        final JLabel label86 = new JLabel();
        label86.setText(" -8  ");
        panel10.add(label86, cc.xy(3, 3));
        final JLabel label87 = new JLabel();
        label87.setText("  1  ");
        panel10.add(label87, cc.xy(3, 5));
        final JLabel label88 = new JLabel();
        label88.setText("  1  ");
        panel10.add(label88, cc.xy(5, 1));
        final JLabel label89 = new JLabel();
        label89.setText("  1  ");
        panel10.add(label89, cc.xy(5, 3));
        final JLabel label90 = new JLabel();
        label90.setText("  1  ");
        panel10.add(label90, cc.xy(5, 5));
        laplasRadioButton1 = new JRadioButton();
        laplasRadioButton1.setSelected(true);
        laplasRadioButton1.setText("");
        laplasPanel.add(laplasRadioButton1, cc.xy(1, 5, CellConstraints.CENTER, CellConstraints.DEFAULT));
        laplasRadioButton2 = new JRadioButton();
        laplasRadioButton2.setText("");
        laplasPanel.add(laplasRadioButton2, cc.xy(3, 5, CellConstraints.CENTER, CellConstraints.DEFAULT));
        final com.intellij.uiDesigner.core.Spacer spacer9 = new com.intellij.uiDesigner.core.Spacer();
        laplasPanel.add(spacer9, cc.xy(1, 3, CellConstraints.DEFAULT, CellConstraints.FILL));
        final com.intellij.uiDesigner.core.Spacer spacer10 = new com.intellij.uiDesigner.core.Spacer();
        laplasPanel.add(spacer10, cc.xy(3, 3, CellConstraints.DEFAULT, CellConstraints.FILL));
        detectEdgesButton = new JButton();
        this.$$$loadButtonText$$$(detectEdgesButton, ResourceBundle.getBundle("pl/us/ij/plugins/segmentation/localization/Localization").getString("edgesMasksForm.detectEdgesLabel"));
        masksPanel.add(detectEdgesButton, cc.xy(3, 3, CellConstraints.FILL, CellConstraints.BOTTOM));
        ButtonGroup buttonGroup;
        buttonGroup = new ButtonGroup();
        buttonGroup.add(robertsRadioButton1);
        buttonGroup.add(robertsRadioButton2);
        buttonGroup.add(robertsRadioButton3);
        buttonGroup.add(robertsRadioButton4);
        buttonGroup = new ButtonGroup();
        buttonGroup.add(prewittRadioButton1);
        buttonGroup.add(prewittRadioButton2);
        buttonGroup = new ButtonGroup();
        buttonGroup.add(sobelRadioButton1);
        buttonGroup.add(sobelRadioButton2);
        buttonGroup = new ButtonGroup();
        buttonGroup.add(laplasRadioButton1);
        buttonGroup.add(laplasRadioButton2);
    }

    /**
     * @noinspection ALL
     */
    private void $$$loadButtonText$$$(AbstractButton component, String text) {
        StringBuffer result = new StringBuffer();
        boolean haveMnemonic = false;
        char mnemonic = '\0';
        int mnemonicIndex = -1;
        for (int i = 0; i < text.length(); i++) {
            if (text.charAt(i) == '&') {
                i++;
                if (i == text.length()) break;
                if (!haveMnemonic && text.charAt(i) != '&') {
                    haveMnemonic = true;
                    mnemonic = text.charAt(i);
                    mnemonicIndex = result.length();
                }
            }
            result.append(text.charAt(i));
        }
        component.setText(result.toString());
        if (haveMnemonic) {
            component.setMnemonic(mnemonic);
            component.setDisplayedMnemonicIndex(mnemonicIndex);
        }
    }
}
